import { baseRequestClient, requestClient } from '#/api/request';

export namespace RtVendor {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    [x: string]: any;
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date | null;
    remark: string;
    params: Params;
    rtId: number;
    rtCode: string;
    rtName: string;
    poCode: null | string;
    vendorId: string;
    vendorCode: string;
    vendorName: string;
    vendorNick: string;
    batchId: null;
    batchCode: null;
    rtDate: Date;
    rtReason: string;
    transportCode: null | string;
    transportTel: null | string;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getRtVendorTableList = (params: RtVendor.GetListParams) =>
  requestClient.get<RtVendor.GetListReturn>('/mes/wm/rtvendor/list', {
    params,
  });
// 增加采购退货
export const addRtVendor = (data: RtVendor.Row) =>
  requestClient.post<RtVendor.GetListReturn>('/mes/wm/rtvendor', data);

// 删除采购退货
export const deleteRtVendor = (id: string) =>
  requestClient.delete<RtVendor.GetListReturn>(`/mes/wm/rtvendor/${id}`);

// 修改采购退货
export const updateRtVendor = (data: RtVendor.Row) =>
  requestClient.put<RtVendor.GetListReturn>('/mes/wm/rtvendor', data);

export const getRtVendorCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/WM_RTVENDOR_CODE');
